package com.wen.task.customTask;

import com.wen.moudle.Account;
import com.wen.moudle.Managers.BackpackManager;
import com.wen.task.AbstractTask;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class UseGem extends AbstractTask {
    BackpackManager backpackManager;

    public UseGem(Account account) {
        super(account);
        backpackManager = getBackpackManager();
    }

    @Override
    public void run() {
        combineGem("一级宝石");
        combineGem("二级宝石");
        combineGem("三级宝石");
        combineGem("四级宝石");
        combineGem("五级宝石");
        combineGem("六级宝石");
    }

    @Override
    public String getTitle() {
        return "一键融合宝石";
    }

    public void combineGem(String name){
        int id = backpackManager.getGoodId(name);
        int count = 0;
        int group = 0;
        while (backpackManager.combineGood(id).isSuccess()){
            count++;
            group++;
            if (group == 20){
                group = 0;
                log.info("使用了 {} 个 {}", count,name);
            }
        };
        log.info("使用了 {} 个 {}", count,name);
    }


}
